package fr.adfm.entity;

import java.util.Collection;
import java.util.Date;
import java.util.LinkedHashSet;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

@Entity
public class BonCommande {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
	
	public Long getId() {
		return id;
	}
		
	@OneToOne
	private Client client;
	
	@OneToOne(cascade=CascadeType.ALL)
	private EtatTraitementBonCommande etatTraitementBonCommande;
	
	@OneToOne(cascade=CascadeType.ALL)
	private Adresse adresseLivraison;
	
	private Date dateCreation;
	private Double fraisDePort;
	private Double montantTotal;
	
	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
	@JoinColumn(name="BonCommande_ID")
	private Collection<BonCommandeLigne> lignes = new LinkedHashSet<BonCommandeLigne>();

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public Date getDateCreation() {
		return dateCreation;
	}
	
	public Adresse getAdresseLivraison() {
		return adresseLivraison;
	}

	public void setAdresseLivraison(Adresse adresseLivraison) {
		this.adresseLivraison = adresseLivraison;
	}

	public void setDateCreation(Date dateCreation) {
		this.dateCreation = dateCreation;
	}

	public Double getFraisDePort() {
		return fraisDePort;
	}

	public void setFraisDePort(Double fraisDePort) {
		this.fraisDePort = fraisDePort;
	}

	public Double getMontantTotal() {
		return montantTotal;
	}

	public void setMontantTotal(Double montantTotal) {
		this.montantTotal = montantTotal;
	}

	public Collection<BonCommandeLigne> getLignes() {
		return lignes;
	}

	public void setLignes(Collection<BonCommandeLigne> lignes) {
		this.lignes = lignes;
	}

	public EtatTraitementBonCommande getEtatTraitementBonCommande() {
		return etatTraitementBonCommande;
	}

	public void setEtatTraitementBonCommande(
			EtatTraitementBonCommande etatTraitementBonCommande) {
		this.etatTraitementBonCommande = etatTraitementBonCommande;
	}

}
